Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polygon field added #155

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

polygon field added #155

wants to merge 3 commits into from

Conversation

soheildsh
Copy link

I tried to add polygon field from geodjango. thanks for you consideration.

@codecov-io
Copy link

codecov-io commented Feb 22, 2021

Codecov Report

Merging #155 (60929b6) into master (480b6b9) will decrease coverage by 1.16%.
The diff coverage is 80.26%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #155      +/-   ##
==========================================
- Coverage   93.67%   92.51%   -1.17%     
==========================================
  Files           9        9              
  Lines         759      855      +96     
==========================================
+ Hits          711      791      +80     
- Misses         48       64      +16     
Impacted Files Coverage Δ
drf_extra_fields/geo_fields.py 86.95% <78.57%> (-5.73%) ⬇️
tests/test_fields.py 95.02% <81.25%> (-1.81%) ⬇️
drf_extra_fields/fields.py 90.05% <0.00%> (+0.17%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 480b6b9...60929b6. Read the comment docs.

35.59925232772949
]
]
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't support polygon with inner rings.

How about we use the following format with the key coordinates?

Polygon with single ring (The way you implemented.)

coordinates : [
     [ [ 2 , 2 ] , [ 3 , 3 ] , [ 4 , 2 ] , [ 2 , 2 ] ]
  ]

Polygon with multiple rings (The one that is not supported at the moment.)

coordinates : [
     [ [ 0 , 0 ] , [ 3 , 6 ] , [ 6 , 1 ] , [ 0 , 0 ] ],
     [ [ 2 , 2 ] , [ 3 , 3 ] , [ 4 , 2 ] , [ 2 , 2 ] ]
  ]

From geojson specification

The "coordinates" member must be an array of LinearRing coordinate arrays. For Polygons with multiple rings, the first must be the exterior ring and any others must be interior rings or holes.

Please see django documentation for usage.

@alicertel
Copy link
Contributor

Hi @yekmolsoheil Thank you for the great addition. I've made a suggestion to make it more compatible with django's Polygon field.

@soheildsh
Copy link
Author

Hi. I'm on it. Soon I will also add the things that you said. thanks for your consideration and excellent review and additions.

@soheildsh soheildsh closed this Aug 15, 2021
@soheildsh soheildsh reopened this Aug 15, 2021
@soheildsh
Copy link
Author

Hey. Polygons with interior rings are added to be supported. also the tests have been passed. Can you now try to review this one more time. If the code is ok we may proceed to add this feature. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants